﻿<UserControl x:Class="Export.Ui.Pages.Admin.UserMaintanance"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cmd="http://www.galasoft.ch/mvvmlight"
             mc:Ignorable="d" 
             d:DesignHeight="350" d:DesignWidth="300"
             DataContext="{Binding Path=Main, Source={StaticResource ViewModelLocator}}">
    <Grid Style="{StaticResource ContentRoot}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ScrollViewer Margin="0,0,0,56" Grid.ColumnSpan="2">
            <StackPanel MinHeight="200">
            <DataGrid x:Name="usersGrid"
                            ItemsSource="{Binding UserMaintanance.Users}"
                            SelectedItem="{Binding UserMaintanance.SelectedUser}"
                           SelectedIndex="{Binding UserMaintanance.SelectedUserIndex}"
                            AutoGenerateColumns="False" IsReadOnly="True">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <cmd:EventToCommand Command="{Binding UserMaintanance.MouseDoubleClickCommand}"  
                                CommandParameter="{Binding ElementName=usersGrid, Path=SelectedItem}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding UserName}" ClipboardContentBinding="{x:Null}" Header="UserName"/>
                    <DataGridTextColumn Binding="{Binding Password}" ClipboardContentBinding="{x:Null}" Header="Password"/>
                    <DataGridTextColumn Binding="{Binding Email}" ClipboardContentBinding="{x:Null}" Header="Email"/>
                    <DataGridTextColumn Binding="{Binding FullName}" ClipboardContentBinding="{x:Null}" Header="Name"/>
                    <DataGridComboBoxColumn ClipboardContentBinding="{x:Null}" SelectedValueBinding="{x:Null}" SelectedItemBinding="{x:Null}" TextBinding="{x:Null}"/>
                    <DataGridTextColumn Binding="{Binding Telephone}" ClipboardContentBinding="{x:Null}" Header="Phone No."/>
                    <DataGridTextColumn Binding="{Binding Fax}" ClipboardContentBinding="{x:Null}" Header="Fax No."/>
                    <DataGridTextColumn Binding="{Binding PinCode}" ClipboardContentBinding="{x:Null}" Header="PinCode"/>
                    <DataGridCheckBoxColumn Binding="{Binding Active}" ClipboardContentBinding="{x:Null}" Header="IsActive"/>
                </DataGrid.Columns>
            </DataGrid>
            </StackPanel>
        </ScrollViewer>
        <Button Command="{Binding UserMaintanance.NewCommand}" Content="New" HorizontalAlignment="Left" Margin="5,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Height="26"/>
        <Button Command="{Binding UserMaintanance.EditCommand}" Content="Edit" Grid.Column="1" HorizontalAlignment="Left" Margin="8,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75"/>
    </Grid>
</UserControl>
